﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace GCT.Foundation
{
    public class FoundationTemplateAppServiceBase : FoundationAppServiceBase
    {
        protected FoundationTemplateAppServiceBase()
        {
            LocalizationSourceName = FoundationTemplateConfigs.Localization.SourceName;
        }

        /// <summary>
        /// 忽略xml json配置文件首字母大小写
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected string ConfigNameFormat(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return name;
            }

            try
            {
                if (name.IndexOf('.') > 0)
                {
                    var nameArray = name.Split('.');
                    return nameArray[0][0].ToString().ToLower() + nameArray[0].Substring(1, nameArray[0].Length - 1) + "." + nameArray[1][0].ToString().ToLower() +
                           nameArray[1].Substring(1, nameArray[1].Length - 1);
                }
                else
                {
                    return name[0].ToString().ToLower() + name.Substring(1, name.Length - 1);
                }
            }
            catch (Exception)
            {
                return name;
            }
        }
    }
}
